package com.webank.wedatasphere.qualitis.rule.dao.repository;

import com.webank.wedatasphere.qualitis.rule.entity.SqlTaskInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface SqlTaskRepository extends JpaRepository<SqlTaskInfo, Long> {

    SqlTaskInfo findByRuleName(String ruleName);

    List<SqlTaskInfo> findByProjectId(String projectId);

    List<SqlTaskInfo> findByProjectIdAndSort(String projectId,int sort);

    @Query(value = "SELECT max(tr.sort) from SqlTaskInfo tr where tr.projectId = ?1")
    int getMaxSortByProjectId(String projectId);


    SqlTaskInfo findByProjectIdAndSortAndRuleNewId(String projectId,int sort,long ruleNewId);


}
